//
//  ZZAllCityViewController.swift
//  enjoy
//
//  Created by 张鹏 on 16/6/7.
//  Copyright © 2016年 ZP. All rights reserved.
//

import UIKit

let KWidth = UIScreen.mainScreen().bounds.size.width
var imageCount : CGFloat = 5

class ZZAllCityViewController: UITableViewController,ZJCycleViewDelegate {
    //视图已经加载
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: self, action: nil)
        
        self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
        
        addTableHeaderView()
        
        buildNavigationItem()
    
    }
    
    private func addTableHeaderView() {
    
        //设置tableHeaderView
        let tabHeaderView = UIView()
        tabHeaderView.frame = CGRectMake(0, 0, KWidth, 150)
        tabHeaderView.backgroundColor = UIColor.redColor()
        self.tableView.tableHeaderView = tabHeaderView

        //设置collectionView
        let cycle = ZJCycleScrollView.init(frame: CGRectMake(0, 0, width, 150))
        cycle.delegate = self;
        let images: NSMutableArray = ["http://images11.app.happyjuzi.com/news/201604/12/570c656b35ae9.jpg", "http://images11.app.happyjuzi.com/news/201604/12/570c8bc8e0b33.jpg", "http://images11.app.happyjuzi.com/news/201604/12/570c656b35ae9.jpg", "http://images11.app.happyjuzi.com/news/201604/12/570c8bc8e0b33.jpg"]
        cycle.images = images
        
        self.view.addSubview(cycle)
        
    }
    
    func didSelectIndexCollectionViewCell(index: Int) {
        print("\(index)")
        //TODO: 未完待续  在此方法中根据图片数组的角标判断,不同的图片加载不同的h5界面
    }

    private func buildNavigationItem() {

        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "分类", style:.Plain, target: self, action: #selector(ZZAllCityViewController.btnClick))
        
        self.navigationItem.leftBarButtonItem?.tintColor = UIColor.whiteColor()
        
        //searchbar_textfield_search_icon
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "searchbar_textfield_search_icon"), style: .Plain, target: self, action: #selector(ZZAllCityViewController.btnClick1))

    }
    
    func btnClick() {

        self.navigationController?.pushViewController(ZZHomeTableViewController(), animated: true)
    }
    
    func btnClick1() {
        
        self.navigationController?.pushViewController(ZZAllCountryViewController(), animated: true)
    }
}
